<template>
	<view class="record-container">
		<info-item v-if="checkPointList" :infoList="checkPointList"></info-item>
		<view v-else>
			<van-empty description="暂无记录" />
		</view>
		<uni-load-more v-if="checkPointList && checkPointList.length >= 10" :status="status" />
	</view>
</template>

<script>
	import InfoItem from '../components/infoItem.vue'
	export default {
		components: {
			InfoItem
		},
		data() {
			return {
				status: 'more',
				params: {
					所属网格id: null,
					检查点名称: null,
					网格员: null,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "id",
						order: 0
					}
				},
				checkPointList: []
			}
		},
		onLoad() {
			this.params.所属网格id = uni.getStorageSync('gridInfo').所属网格id
			this.params.网格员 = uni.getStorageSync('gridInfo').人员姓名
			this.getCheckPointList()
		},
		onReachBottom() {
			// console.log('触发上拉')
			if(this.status !== 'noMore' && this.checkPointList) {
				this.status = 'loading'
				this.getMoreCheckPointList()
			}
		},
		methods: {
			getCheckPointList() {
				uni.showLoading({
					mask: true
				})
				this.$http.post('gridSystem/checkPoint/list', this.params).then(res => {
					console.log(res)
					if(res.code === 10000){
						this.checkPointList = res.data.list
					}
				})
			},
			getMoreCheckPointList() {
				this.params.pagination.current++
				this.$http.post('gridSystem/checkPoint/list', this.params).then(res => {
					console.log(res)
					if(res.code === 10000){
						if(res.data.list !== null) {
							this.checkPointList = this.checkPointList.concat(res.data.list)
						}
						if(this.checkPointList.length === res.data.total){
							this.status = 'noMore'
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.van-empty {
		background-color: #fff;
	}
	.record-container {
		background-color: #F5F5F5;
		padding-top: 20rpx;
	}
</style>
